package app.qrcode.browser.ykpixabay.logic.dao

import android.content.Context
import app.qrcode.browser.ykpixabay.MyApplication

/**
 * Created by YiGo on 2022/4/17.
 */
object KeyDao {
    fun saveKey(Key: String) {
        sharePreferences().edit().putString("key", Key).apply()
    }

    fun deleteKey() = sharePreferences().edit().clear().apply()


    fun getKey() = sharePreferences().getString("key", "")

    fun isKeySaved() = sharePreferences().contains("key")

    private fun sharePreferences() =
        MyApplication.context.getSharedPreferences("Pixkey", Context.MODE_PRIVATE)
}